
<form class="layui-form pt10" action="{:url()}" method="post" id="editForm">

    <div class="layui-form-item">
        <label class="layui-form-label">会员</label>
        <div class="layui-input-inline">
            <select lay-filter="selectBalance" name="user_id" class="layui-input field-user_id" {if isset($formData.user_id)} disabled {/if}  lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
              {$users|raw}
            </select>
        </div>
        <div class="account_balance layui-form-mid layui-word-aux"></div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">顾问</label>
        <div class="layui-input-inline">
            <select name="adviser_id" class="layui-input field-adviser_id" lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
              {$advisers|raw}
            </select>
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">美容师</label>
        <div class="layui-input-inline">
            <div id="technician_id" style="width: 100%; "></div>
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">疗程/产品卡</label>
        <div class="layui-input-inline">
            <select name="course_id" class="layui-input field-course_id" {if isset($formData.course_id)} disabled {/if} lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
              {$courses|raw}
            </select>
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">数量</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-num" name="num" {if isset($formData.num)} disabled {/if} value="1.00" lay-verify="number" autocomplete="off" ">
        </div>
        <div class="layui-form-mid layui-word-aux" >注：数量请谨慎使用小数！</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">售价</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-price1" name="price1" {if isset($formData.price1)} disabled {/if} value="0.00" lay-verify="number" autocomplete="off" ">
        </div>
        <div class="layui-form-mid layui-word-aux">注：商品价格按售价计算！实交、欠款做定金备注使用</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">实交</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-q1" name="q1"  value="0.00" lay-verify="number" autocomplete="off" ">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">欠款</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-q2" name="q2"  value="0.00" lay-verify="number" autocomplete="off" ">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收款账户</label>
        <div class="layui-input-inline">
            <select  name="account_id" class="layui-input field-account_id" {if isset($formData.account_id)} disabled {/if} lay-verify="required" lay-search="">
              <option value="">直接选择或搜索选择</option>
              {$accounts|raw}
            </select>
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-bak" name="bak"  lay-verify="" autocomplete="off" ">
        </div>
    </div>
    {if isset($formData['id']) && $admin_type == '财务'}
    <div class="layui-form-item">
        <label class="layui-form-label">审核</label>
        <div class="layui-input-inline">
            <input type="radio" class="field-status" name="status" value="2" title="通过" checked>
            <input type="radio" class="field-status" name="status" value="3" title="不通过">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
        <input type="hidden" class="field-finance_id" name="finance_id" value="{:ADMIN_ID}">
    </div>
    {else}
    <input type="hidden" class="field-cashier_id" name="cashier_id" value="{:ADMIN_ID}">
    <input type="hidden" class="field-sn" name="sn" value="{:create_order_sn()}">
    <input type="hidden" class="field-shop_id" name="shop_id" value="{:session('shop_id')}">
    {/if}
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" class="field-id" name="id">
        </div>
    </div>
    <div class="pop-bottom-bar hisi-footer">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>
<!-- <script src="__PUBLIC_JS__/layui/xm-select.js" charset="utf-8"></script> -->
{include file="system@block/layui" /}

<script>

layui.use(['func','laydate','xmSelect'], function() {
    //常规用法
    var laydate = layui.laydate;
    var xmSelect = layui.xmSelect;
    var form = layui.form
    laydate.render({
          elem: '#date',
          trigger:'click',
          type:'datetime'
        });
var technician_id = xmSelect.render({
        el: '#technician_id',
        autoRow: true,
        name:'technician_id',
        data: {:json_encode($technicians,true)},
    })
    technician_id.setValue({:isset($formData.technician_id) ? json_encode($formData.technician_id,true) : ''})

    layui.func.assign({:json_encode($formData)});
    form.on('select(selectBalance)', function (data) {
        var user_id = data.value
        console.log(user_id)
        $.ajax({
            url:"{:url('getAccountBalance')}",
            type:'get',
            data:{user_id:user_id},
            success:function(res){
                $('.account_balance').html('会员卡余额：' + res.balance + '元' + '赠送会员卡：' + res.balance2 + '元');
            }
        })
    });

});
</script>
